<template>
	<view>
		<!-- <u-navbar
            title="object1.categoryName"
            @rightClick="rightClick"
            :autoBack="true"
        >
        </u-navbar> -->
		<view>
			<!-- <image src="../../static/c1.png" class="center"></image> -->
			<view class="v-4">{{object1.categoryName}}</view>
		</view>
			<scroll-view v-for="(item,i) in articleList" :key="i" class="vn2" scrolltolower="onReachBottom">
				<!-- <articlce :item1="item"></articlce> -->
				<view  class="article">
					<navigator :url="'/pages/ArticleContent/ArticleContent?id='+ encodeURIComponent(JSON.stringify(item.id))">
						<view class="article-main">
							<view class="article-title">{{item.title}}</view>
							<view >{{item.summary}}</view>
						</view>
					</navigator>
					<view class="article-bottom">
						<view class="article-bottom-tag">
							<view v-for="(iom,u) in item.tags" :key="u" class="article-bottom-tag-size">{{iom.tagName}}</view>
						</view>
						<view  class="article-bottom-li" >
							<view style="display: flex;"><u-icon name="account-fill" /><view>{{item.author}}</view></view>
							<view style="display: flex;"><u-icon name="eye-fill" /><view>{{item.viewCounts}}</view></view>
							<view style="display: flex;"><u-icon name="clock-fill" /><view>{{item.createDate}}</view></view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				object1:{},
				articleList:[],
				titleValue:""
			};
		},
		onLoad(option) {
			const id = JSON.parse(decodeURIComponent(option.id));
			console.log(id);
			this.getcategory(id);
			this.getArticle(id);
			this.title();
		},
		methods:{
			async getcategory(id){
				const {data : ros} =await uni.$http.get(`/categorys/detail/${id}`)
				if(ros.code!==200) return uni.$showMsg()
				this.object1=ros.data
				this.titleValue=ros.data.categoryName
				wx.setNavigationBarTitle({
					title:titleValue
				})
				console.log(ros);
				// .then((ros) => {
				//     // 处理成功响应  
				//     console.log(ros); // 打印返回的数据  
				// }) 
			},
			async getArticle(id){
				const { data : res} =await uni.$http.post('/articles',{
					page:1,
					pageSize:5,
					categoryId: id,
					sort:"desc"
				})
				if(res.code!==200) return uni.$showMsg()
				this.articleList=res.data
				console.log(res);
				// .then((res) => {  
				//     // 处理成功响应  
				//     console.log(res); // 打印返回的数据  
				// }) 
			},
			title(){
				// wx.setNavigationBarTitle({
				// 	title:
				// })
			}
		}
	}
</script>

<style lang="scss">
// .center{
// 	text-align: center;
// 	margin: 0 auto; /* 设置框的水平位置居中 */
// }
.v-4{
	text-align: center;
	text-shadow:red 4px 4px 5px;
	font-size: 30rpx;
	font-weight: 3000;
}
// .n1{
// 	display: flex;
// 	justify-content: space-around;
// 	background-color: aqua;
// 	.v1{
// 		height: 30px;
// 		width: 100%;
// 		text-align: center;
// 	}
// }
// .v2{
// 	display: flex;
// 	justify-content: space-around;
// 	background-color: beige;
// }
// .vn21{
// 	background-color: azure;
// 	border-radius: 10px;
// 	border: 5px;
// 	border-color: black;
// 	height: 200rpx;
// }
// .v3{
// 	background-color: dimgrey;
// 	height: 5px;
// }
// .v4{
// 	text-align: center;
// 	text-shadow:black 4px 4px 5px;
// 	font-size: 30rpx;
// 	font-weight: 3000;
// }
.article {
	padding: 15px;
	.article-main{
		display: flex;
		flex-direction: column;
		.article-title{
			// text-align: center;
			// 文字阴影 text-shadow:black 4px 4px 5px;
			font-size: 40rpx;
			font-weight: 900;
		}
	}
	.article-bottom{
		display: flex;
	    margin-top: 15px;
		position: relative;
		.article-bottom-li{
			display: flex;
			font-size: 25rpx;
			position: absolute;
			right: 2px;
			.article-bottom-li-yuansu{
			}
		}
		.article-bottom-tag{
			display: flex;
			.article-bottom-tag-size{
				margin-left: auto;
				width:fit-content;
				height: auto;
				border-radius: 8rpx;
				background: #99a9bf;
				text-align: center;
			}
		}
		// margin-top: 10px;
		// justify-content: flex-end;
	}
}
.vn2{
	background-color: #ffffff;
	border: 2px solid #f0f0f0;
}
</style>